package net.inteidee.test;

import java.io.IOException;

import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.callback.UnsupportedCallbackException;

public class MyCallBackHandler implements CallbackHandler {

	
	private String nomeUtente;
	private String password;
	private String nomeApplicazione;
	
	
	
	public MyCallBackHandler() {
		// TODO Auto-generated constructor stub
	}
	
	public MyCallBackHandler(String nomeUtente, String password,
			String nomeApplicazione) {
		super();
		this.nomeUtente = nomeUtente;
		this.password = password;
		this.nomeApplicazione = nomeApplicazione;
	}
	
	
	@Override
	public void handle(Callback[] callbacks) throws IOException,
			UnsupportedCallbackException {
		// TODO Auto-generated method stub
		System.out.println("Sto eseguendo questa CallBack");
		
		 ((NameCallback)callbacks[0]).setName(nomeUtente);
		 ((PasswordCallback)callbacks[1]).setPassword(password.toCharArray());
		 ((NameCallback)callbacks[2]).setName(nomeApplicazione);

		
	}

}
